import 'package:amap_location_fluttify/amap_location_fluttify.dart';
import 'package:flutter/material.dart';

///入口provider
class IndexPageProvider with ChangeNotifier {
  ///定位结果
  Location location;

  ///经纬度
  LatLng latLng;

  ///当前城市
  String currentCity;

  ///设置定位结果
  void setLocation(Location location) async {
    this.location = location;

    this.latLng = await location.latLng;
    String province = await location.province;
    String city = await location.city;
    String district = await location.district;

    if (province == city) {
      this.currentCity = district;
    } else {
      this.currentCity = city;
    }

    notifyListeners();
  }
}
